package com.smileus;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.smileus.entity.IntegrationLogs;

public class TimeTask2 {
	private static BlockingQueue<IntegrationLogs> logsQueue = new LinkedBlockingQueue<IntegrationLogs>();

	public static void main(String[] args) {
		final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();

		for (int i = 0; i < 1000; i++) {
			logsQueue.add(new IntegrationLogs());
		}
		final Runnable beeper = new Runnable() {
			int count = 0;

			public void run() {
				System.out.println(logsQueue.peek().getGmtCreate() + "beep" + (++count));
			}
		};
		// 1秒钟后运行，并每隔2秒运行一次
		scheduler.scheduleAtFixedRate(beeper, 1, 2, TimeUnit.SECONDS);
	}
}
